--
-- PostgreSQL database dump
--

-- Dumped from database version 9.0.3
-- Dumped by pg_dump version 9.0.3
-- Started on 2011-05-08 19:34:50

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- TOC entry 325 (class 2612 OID 11574)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres
--

CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;


ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 1517 (class 1259 OID 16839)
-- Dependencies: 6
-- Name: CATEGORIAS; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "CATEGORIAS" (
    cod_categoria character varying(10) NOT NULL,
    nombre_corto character(15),
    nombre_largo character varying(30),
    status "char"
);


ALTER TABLE public."CATEGORIAS" OWNER TO postgres;

--
-- TOC entry 1518 (class 1259 OID 16842)
-- Dependencies: 6
-- Name: CLIENTES; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "CLIENTES" (
    cod_cliente character varying(12) NOT NULL,
    nombre character varying(30),
    direccion character varying(100),
    telefono character varying(11),
    status "char"
);


ALTER TABLE public."CLIENTES" OWNER TO postgres;

--
-- TOC entry 1519 (class 1259 OID 16845)
-- Dependencies: 6
-- Name: COMPRAS; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "COMPRAS" (
    fecha date,
    total_pagar double precision,
    status "char",
    cod_compra integer NOT NULL,
    porc_impuesto real,
    cod_proveedor character varying(15)
);


ALTER TABLE public."COMPRAS" OWNER TO postgres;

--
-- TOC entry 1520 (class 1259 OID 16848)
-- Dependencies: 6
-- Name: COMPRAS_DETALLES; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "COMPRAS_DETALLES" (
    cod_compra integer NOT NULL,
    cod_ingrediente character varying(15) NOT NULL,
    cantidad double precision,
    precio_unitario double precision,
    status character(1)
);


ALTER TABLE public."COMPRAS_DETALLES" OWNER TO postgres;

--
-- TOC entry 1521 (class 1259 OID 16851)
-- Dependencies: 6
-- Name: INGREDIENTES; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "INGREDIENTES" (
    cod_ingrediente character varying(15) NOT NULL,
    nombre_corto character varying(15),
    nombre_largo character varying(30),
    unidad_medida character varying(5),
    costo double precision,
    status "char",
    existencia double precision
);


ALTER TABLE public."INGREDIENTES" OWNER TO postgres;

--
-- TOC entry 1850 (class 0 OID 0)
-- Dependencies: 1521
-- Name: COLUMN "INGREDIENTES".costo; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN "INGREDIENTES".costo IS 'almacena el costo unitario mas alto comprado';


--
-- TOC entry 1851 (class 0 OID 0)
-- Dependencies: 1521
-- Name: COLUMN "INGREDIENTES".existencia; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN "INGREDIENTES".existencia IS 'almacena la existencia actual del ingrediente; se evita el costo de procesamiento que implica calcular este campo';


--
-- TOC entry 1522 (class 1259 OID 16859)
-- Dependencies: 6
-- Name: PRODUCTOS; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "PRODUCTOS" (
    cod_producto character varying(10) NOT NULL,
    nombre_corto character varying(15),
    nombre_largo character varying(30),
    cod_categoria character varying(10),
    porc_ganancia real,
    status "char"
);


ALTER TABLE public."PRODUCTOS" OWNER TO postgres;

--
-- TOC entry 1523 (class 1259 OID 16862)
-- Dependencies: 6
-- Name: PRODUCTOS_INGREDIENTES; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "PRODUCTOS_INGREDIENTES" (
    cod_producto character varying(10) NOT NULL,
    cod_ingrediente character varying(15) NOT NULL,
    cantidad double precision,
    status character(1)
);


ALTER TABLE public."PRODUCTOS_INGREDIENTES" OWNER TO postgres;

--
-- TOC entry 1852 (class 0 OID 0)
-- Dependencies: 1523
-- Name: TABLE "PRODUCTOS_INGREDIENTES"; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE "PRODUCTOS_INGREDIENTES" IS 'Relaciona los Productos con los Ingredientes que lo componen';


--
-- TOC entry 1524 (class 1259 OID 16865)
-- Dependencies: 6
-- Name: PROVEEDORES; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "PROVEEDORES" (
    cod_proveedor character varying(15) NOT NULL,
    nombre character varying(30),
    direccion character varying(100),
    telefono character varying(11),
    status "char"
);


ALTER TABLE public."PROVEEDORES" OWNER TO postgres;

--
-- TOC entry 1525 (class 1259 OID 16868)
-- Dependencies: 6
-- Name: VENTAS; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "VENTAS" (
    cod_venta integer NOT NULL,
    porc_impuesto real,
    porc_descuento real,
    total_pagar double precision,
    status "char",
    fecha date,
    cod_cliente character varying(12)
);


ALTER TABLE public."VENTAS" OWNER TO postgres;

--
-- TOC entry 1526 (class 1259 OID 16871)
-- Dependencies: 6
-- Name: VENTAS_DETALLES; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE "VENTAS_DETALLES" (
    cod_venta integer NOT NULL,
    cod_producto character varying(10) NOT NULL,
    precio_unitario double precision,
    cantidad integer,
    status character(1)
);


ALTER TABLE public."VENTAS_DETALLES" OWNER TO postgres;

--
-- TOC entry 1835 (class 0 OID 16839)
-- Dependencies: 1517
-- Data for Name: CATEGORIAS; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "CATEGORIAS" VALUES ('CAT-1', 'HAMBURGUESAS   ', 'HAMBURGUESAS', 'A');
INSERT INTO "CATEGORIAS" VALUES ('CAT-3', 'PEPITOS        ', 'PEPITOS', 'A');
INSERT INTO "CATEGORIAS" VALUES ('CAT-4', 'PIZZA          ', 'PIZZA', 'A');
INSERT INTO "CATEGORIAS" VALUES ('CAT-2', 'PERROS         ', 'PERROS CALIENTES', 'A');
INSERT INTO "CATEGORIAS" VALUES ('CAT-5', 'OTROS          ', 'OTROS', 'A');


--
-- TOC entry 1836 (class 0 OID 16842)
-- Dependencies: 1518
-- Data for Name: CLIENTES; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "CLIENTES" VALUES ('V-18249214', 'Jesus Alberto Baute', 'Carrera 21 entre calles 5 y 6', '02512525653', 'A');
INSERT INTO "CLIENTES" VALUES ('E-1824921', 'Kamel Igui', 'Carrera 20, entre calles 23 y 24. Casa Nro 23', '02514562718', 'E');
INSERT INTO "CLIENTES" VALUES ('V-18787954', 'Yurysky Zozzaro', 'Carrera 15 con calle 12. Edif "Los Ilustres", piso 2, apto 2-1.Barquisimeto-Edo Lara', '04267310549', 'A');
INSERT INTO "CLIENTES" VALUES ('V-17545892', 'Fabiola Alvarez', 'Av "Los Ilustres" con calle "El Paseo". Edif "Araguaney", piso 7, apto 7-B.Los Teques-Edo Miranda', '04242962291', 'A');
INSERT INTO "CLIENTES" VALUES ('V-15623881', 'Karla Ramirez', 'Urb "Los Castores". calle "Raul Leoni".Casa Nro 23.San Antonio de los Altos-Edo Miranda', '02125642346', 'A');
INSERT INTO "CLIENTES" VALUES ('E-1634021', 'Sarai Knai', 'Carrera 23 entre calles 4 y 5. Urb "La Paz". Edif "Casacoima", piso 4, apto 4-B.Barqusimeto-Edo Lara', '02512524525', 'A');
INSERT INTO "CLIENTES" VALUES ('V-20558964', 'Gabriela Gimenez', 'Carrera 18, entre calles 54-A y 54-B. Casa Nro 22.Barqusimeto-Edo Lara', '04267389917', 'A');
INSERT INTO "CLIENTES" VALUES ('V-19320123', 'Lorena Diaz', 'Carrera 16 entre calles 13 y 14. casa Nro 7.Barquisimeto-Edo Lara', '02516721623', 'A');
INSERT INTO "CLIENTES" VALUES ('V-18334787', 'Marcos Torrealba Calles', 'Carrera 27 con calle 16, casa Nro 4. Barquisimeto-Edo Lara', '04247829123', 'A');


--
-- TOC entry 1837 (class 0 OID 16845)
-- Dependencies: 1519
-- Data for Name: COMPRAS; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "COMPRAS" VALUES ('2011-04-15', 196, 'A', 1, 12, 'J-01200231-4');
INSERT INTO "COMPRAS" VALUES ('2011-04-15', 515.20000000000005, 'A', 2, 12, 'J-11002123-9');
INSERT INTO "COMPRAS" VALUES ('2011-04-15', 2.5300000000000002, 'A', 3, 10, 'J-67800231-4');
INSERT INTO "COMPRAS" VALUES ('2011-05-07', 373.63200000000001, 'A', 4, 12, 'J-01200231-4');
INSERT INTO "COMPRAS" VALUES ('2011-05-07', 745.22000000000003, 'A', 5, 12, 'J-00795402-1');
INSERT INTO "COMPRAS" VALUES ('2011-05-07', 237.37279999999998, 'A', 6, 12, 'J-00795402-1');


--
-- TOC entry 1838 (class 0 OID 16848)
-- Dependencies: 1520
-- Data for Name: COMPRAS_DETALLES; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "COMPRAS_DETALLES" VALUES (1, 'ING-8', 50, 1.5, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (1, 'ING-5', 1000, 0.10000000000000001, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (2, 'ING-11', 2000, 0.23000000000000001, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (3, 'ING-13', 10, 0.23000000000000001, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (4, 'ING-8', 20, 1.6799999999999999, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (4, 'ING-12', 1000, 0.29999999999999999, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (5, 'ING-1', 670, 0.012500000000000001, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (5, 'ING-4', 2000, 0.29999999999999999, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (5, 'ING-6', 100, 0.01, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (5, 'ING-5', 500, 0.112, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (6, 'ING-10', 710, 0.20000000000000001, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (6, 'ING-1', 710, 0.014, 'A');
INSERT INTO "COMPRAS_DETALLES" VALUES (6, 'ING-9', 200, 0.29999999999999999, 'A');


--
-- TOC entry 1839 (class 0 OID 16851)
-- Dependencies: 1521
-- Data for Name: INGREDIENTES; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "INGREDIENTES" VALUES ('ING-3', 'S. Mostaza', 'Salsa Mostaza', 'GR', 0.012500000000000001, 'A', 400);
INSERT INTO "INGREDIENTES" VALUES ('ING-6', 'Lechuga V', 'Lechuga Verde', 'GR', 0.0112, 'A', 1990);
INSERT INTO "INGREDIENTES" VALUES ('ING-11', 'Carne Lomito', 'Carne Lomito', 'GR', 0.25600000000000001, 'A', 2000);
INSERT INTO "INGREDIENTES" VALUES ('ING-13', 'HARINA', 'HARINA', 'GR', 0.253, 'A', 10);
INSERT INTO "INGREDIENTES" VALUES ('ING-14', 'Repollo', 'Repollo', 'GR', 0.016, 'A', 0);
INSERT INTO "INGREDIENTES" VALUES ('ING-8', 'Salchicha', 'Salchicha', 'Unid', 1.8815999999999999, 'A', 90);
INSERT INTO "INGREDIENTES" VALUES ('ING-12', 'JAMON', 'JAMON PLUMROSE', 'GR', 0.33599999999999997, 'A', 1000);
INSERT INTO "INGREDIENTES" VALUES ('ING-10', 'Mayonesa', 'Mayonesa', 'GR', 0.224, 'A', 1210);
INSERT INTO "INGREDIENTES" VALUES ('ING-2', 'Carne Mchd', 'Carne Mechada', 'GR', 0.20000000000000001, 'A', 340);
INSERT INTO "INGREDIENTES" VALUES ('ING-7', 'Pan de Perro C', 'Pan de Perro Caliente', 'Unid', 2.5, 'A', 16);
INSERT INTO "INGREDIENTES" VALUES ('ING-9', 'Papas Fritas P', 'Papas Fritas Perro Caliente', 'GR', 0.33599999999999997, 'A', 1080);
INSERT INTO "INGREDIENTES" VALUES ('ING-1', 'Salsa Tmte', 'Salsa de Tomate', 'GR', 0.015679999999999999, 'A', 1348);
INSERT INTO "INGREDIENTES" VALUES ('ING-4', 'Carne Molida', 'Carne Molida', 'GR', 0.33599999999999997, 'A', 6780);
INSERT INTO "INGREDIENTES" VALUES ('ING-5', 'Queso A', 'Queso Amarillo', 'GR', 0.12544, 'A', 4270);


--
-- TOC entry 1840 (class 0 OID 16859)
-- Dependencies: 1522
-- Data for Name: PRODUCTOS; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "PRODUCTOS" VALUES ('P-1', 'PEPITO N', 'PEPITO NORMAL', 'CAT-3', 15, 'A');
INSERT INTO "PRODUCTOS" VALUES ('PIZ-1', 'PIZZA NORMAL', 'PIZZA NORMAL', 'CAT-4', 12, 'A');
INSERT INTO "PRODUCTOS" VALUES ('H-2', 'HAMBURGUESA DOB', 'HAMBURGUESA DOBLE', 'CAT-1', 15.3000002, 'A');
INSERT INTO "PRODUCTOS" VALUES ('PC-1', 'PERRO NORMAL', 'PERRO CALIENTE NORMAL', 'CAT-2', 12, 'A');
INSERT INTO "PRODUCTOS" VALUES ('H-1', 'HAMBURGUESA NOR', 'HAMBURGUESA NORMAL', 'CAT-1', 15.3000002, 'A');


--
-- TOC entry 1841 (class 0 OID 16862)
-- Dependencies: 1523
-- Data for Name: PRODUCTOS_INGREDIENTES; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-1', 'ING-1', 10, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-1', 'ING-4', 20, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-1', 'ING-5', 10, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-1', 'ING-6', 10, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('P-1', 'ING-2', 15, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('P-1', 'ING-5', 30, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('P-1', 'ING-7', 1, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('P-1', 'ING-9', 30, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PIZ-1', 'ING-1', 50, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PIZ-1', 'ING-5', 60, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PIZ-1', 'ING-12', 70, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PIZ-1', 'ING-13', 100, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-2', 'ING-1', 20, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-2', 'ING-4', 40, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-2', 'ING-5', 20, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('H-2', 'ING-6', 20, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PC-1', 'ING-1', 10, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PC-1', 'ING-3', 10, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PC-1', 'ING-7', 1, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PC-1', 'ING-8', 1, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PC-1', 'ING-9', 10, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PC-1', 'ING-10', 10, 'A');
INSERT INTO "PRODUCTOS_INGREDIENTES" VALUES ('PC-1', 'ING-14', 5, 'A');


--
-- TOC entry 1842 (class 0 OID 16865)
-- Dependencies: 1524
-- Data for Name: PROVEEDORES; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "PROVEEDORES" VALUES ('J-67800231-4', 'Panaderia "El Portu"', 'carrera 26 entre calles 51 y 52; Barquisimeto Edo Lara', '02519674324', 'A');
INSERT INTO "PROVEEDORES" VALUES ('J-11002123-9', 'Carniceria "Punta Trasera" ', 'carrera 20, entre calles 23 y 24,Barquisimeto Edo Lara', '02512558923', 'A');
INSERT INTO "PROVEEDORES" VALUES ('J-01200231-4', 'Hort Embutidos C.A', 'Carrera 34 entre calles 19 y 49. Barqusimeto, Edo. Lara', '02516784355', 'A');
INSERT INTO "PROVEEDORES" VALUES ('J-00094853-1', 'Agrodistribuidora C.A', 'Av Libertador, con calle 59.Valencia-Edo Carabobo', '02418346474', 'A');
INSERT INTO "PROVEEDORES" VALUES ('J-00795402-1', 'Distribudora "La Paz"', 'Zona Industrial II, carrera 43 entre calles 12 y 13. Galpon 21.Barquisimeto-Edo lara', '02516739917', 'A');


--
-- TOC entry 1843 (class 0 OID 16868)
-- Dependencies: 1525
-- Data for Name: VENTAS; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "VENTAS" VALUES (1, 0, 0, 16, 'A', '2011-04-14', 'V-19320123');
INSERT INTO "VENTAS" VALUES (2, 0, 0, 8, 'A', '2011-04-14', 'V-18249214');
INSERT INTO "VENTAS" VALUES (3, 0, 0, 8, 'A', '2011-04-14', 'V-18249214');
INSERT INTO "VENTAS" VALUES (4, 0, 0, 16, 'A', '2011-04-14', 'V-18249214');
INSERT INTO "VENTAS" VALUES (5, 10, 0, 22, 'A', '2011-04-15', 'V-19320123');
INSERT INTO "VENTAS" VALUES (6, 12, 0, 33.600000000000001, 'A', '2011-05-07', 'V-20558964');
INSERT INTO "VENTAS" VALUES (7, 12, 0, 10.08, 'A', '2011-05-07', 'V-18334787');
INSERT INTO "VENTAS" VALUES (8, 12, 10, 9.0719999999999992, 'A', '2011-05-07', 'V-18334787');
INSERT INTO "VENTAS" VALUES (9, 12, 0, 59.359999999999999, 'A', '2011-05-08', 'V-18787954');


--
-- TOC entry 1844 (class 0 OID 16871)
-- Dependencies: 1526
-- Data for Name: VENTAS_DETALLES; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO "VENTAS_DETALLES" VALUES (1, 'H-1', 8, 2, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (2, 'H-1', 8, 1, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (3, 'H-1', 8, 1, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (4, 'H-1', 8, 2, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (5, 'P-1', 20, 1, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (6, 'H-1', 9, 1, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (6, 'P-1', 21, 1, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (7, 'H-1', 9, 1, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (8, 'H-1', 9, 1, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (9, 'P-1', 22, 2, 'A');
INSERT INTO "VENTAS_DETALLES" VALUES (9, 'H-1', 9, 1, 'A');


--
-- TOC entry 1805 (class 2606 OID 16878)
-- Dependencies: 1517 1517
-- Name: pk_categoria; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "CATEGORIAS"
    ADD CONSTRAINT pk_categoria PRIMARY KEY (cod_categoria);


--
-- TOC entry 1807 (class 2606 OID 16880)
-- Dependencies: 1518 1518
-- Name: pk_cliente; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "CLIENTES"
    ADD CONSTRAINT pk_cliente PRIMARY KEY (cod_cliente);


--
-- TOC entry 1810 (class 2606 OID 16882)
-- Dependencies: 1519 1519
-- Name: pk_compra; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "COMPRAS"
    ADD CONSTRAINT pk_compra PRIMARY KEY (cod_compra);


--
-- TOC entry 1812 (class 2606 OID 16884)
-- Dependencies: 1520 1520 1520
-- Name: pk_compra_detalles; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "COMPRAS_DETALLES"
    ADD CONSTRAINT pk_compra_detalles PRIMARY KEY (cod_compra, cod_ingrediente);


--
-- TOC entry 1814 (class 2606 OID 16886)
-- Dependencies: 1521 1521
-- Name: pk_ingredientes; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "INGREDIENTES"
    ADD CONSTRAINT pk_ingredientes PRIMARY KEY (cod_ingrediente);


--
-- TOC entry 1816 (class 2606 OID 16888)
-- Dependencies: 1522 1522
-- Name: pk_producto; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "PRODUCTOS"
    ADD CONSTRAINT pk_producto PRIMARY KEY (cod_producto);


--
-- TOC entry 1818 (class 2606 OID 16890)
-- Dependencies: 1523 1523 1523
-- Name: pk_producto_ingrediente; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "PRODUCTOS_INGREDIENTES"
    ADD CONSTRAINT pk_producto_ingrediente PRIMARY KEY (cod_producto, cod_ingrediente);


--
-- TOC entry 1820 (class 2606 OID 16951)
-- Dependencies: 1524 1524
-- Name: pk_proveedores; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "PROVEEDORES"
    ADD CONSTRAINT pk_proveedores PRIMARY KEY (cod_proveedor);


--
-- TOC entry 1823 (class 2606 OID 16894)
-- Dependencies: 1525 1525
-- Name: pk_venta; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "VENTAS"
    ADD CONSTRAINT pk_venta PRIMARY KEY (cod_venta);


--
-- TOC entry 1825 (class 2606 OID 16896)
-- Dependencies: 1526 1526 1526
-- Name: pk_venta_detalles; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY "VENTAS_DETALLES"
    ADD CONSTRAINT pk_venta_detalles PRIMARY KEY (cod_venta, cod_producto);


--
-- TOC entry 1808 (class 1259 OID 16961)
-- Dependencies: 1519
-- Name: fki_compras_proveedor; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX fki_compras_proveedor ON "COMPRAS" USING btree (cod_proveedor);


--
-- TOC entry 1821 (class 1259 OID 16899)
-- Dependencies: 1525
-- Name: fki_venta_clientes; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX fki_venta_clientes ON "VENTAS" USING btree (cod_cliente);


--
-- TOC entry 1829 (class 2606 OID 16900)
-- Dependencies: 1804 1522 1517
-- Name: fk_categorias_productos; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "PRODUCTOS"
    ADD CONSTRAINT fk_categorias_productos FOREIGN KEY (cod_categoria) REFERENCES "CATEGORIAS"(cod_categoria) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1827 (class 2606 OID 16905)
-- Dependencies: 1520 1809 1519
-- Name: fk_compra_detalles_compra; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "COMPRAS_DETALLES"
    ADD CONSTRAINT fk_compra_detalles_compra FOREIGN KEY (cod_compra) REFERENCES "COMPRAS"(cod_compra) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1828 (class 2606 OID 16910)
-- Dependencies: 1521 1520 1813
-- Name: fk_compra_detalles_ingredientes; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "COMPRAS_DETALLES"
    ADD CONSTRAINT fk_compra_detalles_ingredientes FOREIGN KEY (cod_ingrediente) REFERENCES "INGREDIENTES"(cod_ingrediente) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1826 (class 2606 OID 16962)
-- Dependencies: 1819 1519 1524
-- Name: fk_compras_proveedor; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "COMPRAS"
    ADD CONSTRAINT fk_compras_proveedor FOREIGN KEY (cod_proveedor) REFERENCES "PROVEEDORES"(cod_proveedor) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1830 (class 2606 OID 16925)
-- Dependencies: 1521 1523 1813
-- Name: fk_productos_ingredientes_ingredientes; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "PRODUCTOS_INGREDIENTES"
    ADD CONSTRAINT fk_productos_ingredientes_ingredientes FOREIGN KEY (cod_ingrediente) REFERENCES "INGREDIENTES"(cod_ingrediente) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1831 (class 2606 OID 16930)
-- Dependencies: 1523 1522 1815
-- Name: fk_productos_ingredientes_productos; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "PRODUCTOS_INGREDIENTES"
    ADD CONSTRAINT fk_productos_ingredientes_productos FOREIGN KEY (cod_producto) REFERENCES "PRODUCTOS"(cod_producto) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1832 (class 2606 OID 16935)
-- Dependencies: 1806 1518 1525
-- Name: fk_venta_clientes; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "VENTAS"
    ADD CONSTRAINT fk_venta_clientes FOREIGN KEY (cod_cliente) REFERENCES "CLIENTES"(cod_cliente) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1833 (class 2606 OID 16940)
-- Dependencies: 1525 1526 1822
-- Name: fk_venta_detalles_venta; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "VENTAS_DETALLES"
    ADD CONSTRAINT fk_venta_detalles_venta FOREIGN KEY (cod_venta) REFERENCES "VENTAS"(cod_venta) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1834 (class 2606 OID 16945)
-- Dependencies: 1522 1526 1815
-- Name: fk_venta_productos; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "VENTAS_DETALLES"
    ADD CONSTRAINT fk_venta_productos FOREIGN KEY (cod_producto) REFERENCES "PRODUCTOS"(cod_producto) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1849 (class 0 OID 0)
-- Dependencies: 6
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


-- Completed on 2011-05-08 19:34:56

--
-- PostgreSQL database dump complete
--

